package com.it.ems.service.impl;

import com.it.ems.entity.Role;
import com.it.ems.mapper.RoleMapper;
import com.it.ems.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    
    @Autowired
    private RoleMapper roleMapper;
    
    @Override
    public Role findById(Long id) {
        return roleMapper.findById(id);
    }
    
    @Override
    public Role findByName(String name) {
        return roleMapper.findByName(name);
    }
    
    @Override
    public List<Role> findAll() {
        return roleMapper.findAll();
    }
    
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean save(Role role) {
        return roleMapper.insert(role) > 0;
    }
    
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean update(Role role) {
        return roleMapper.update(role) > 0;
    }
} 